package org.example.spring_aop.proxy;

import org.springframework.cglib.proxy.Enhancer;

import java.lang.reflect.Proxy;

public class Main {
    public static void main(String[] args) {
//        HouseProxy proxy=new HouseProxy(new RealHouseSubject());
//        proxy.rent();
//        proxy.sale();
//        HouseSubject target=new RealHouseSubject();
//        HouseSubject proxy=(HouseSubject) Proxy.newProxyInstance(target.getClass().getClassLoader(),
//                new Class[]{HouseSubject.class},new JDKInvocation(target));
//        HouseSubject proxy=(HouseSubject) Proxy.newProxyInstance(target.getClass().getClassLoader(),
//                target.getClass().getInterfaces(),new JDKInvocation(target));
//        proxy.rent();
//        proxy.sale();
        HouseSubject target=new RealHouseSubject();
        HouseSubject proxy = (HouseSubject) Enhancer.create(target.getClass(),new CGLibMethodInterceptor(target));
        proxy.rent();
    }
}
